Display wire-protocol when using --raw #520
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket(s): FE-6242
Problem
One might expect the wire-protocol when using
--raw
, but we currently query using the "simple" format, which loses information.Solution
This PR updates the
--raw
option to force rendering the wire-protocol for successful query data. It assumes that rendering multiple formats are not desired.Other changes
It's safe to make
url
option required, since we do provide it everywhere.we don't provide a custom
client
argument anywhere, so I've removed that as an optional argument for therunQuery
family of functions. It might cause a problem with the injected httpClient if we start passing in Client instances constructed elsewhere.For v10 queries:
If
--raw
is specified, then the API Format is driven to be JSON, which means we will make queries with the "simple" format, in which the Fauna API sends a plain JSON response, and the Client reads it without any special decoding. We leverage that in this PR by providing a custom HTTPClient when--raw
is specified. This client overrides thex-format
header to betagged
. Since the client expects plain JSON, no special decoding is performed, and the wire protocol is forwarded on the caller, and we keep all the benefits of using the driver, e.g. error handling.For v4 queries
No changes here, since querying with
apiVersion 4
already returns the wire protocol. This works because--raw
drives the output to be JSON, and the v4 driver provides toJSON implementation forValues
andExpr
to be the wire protocol.Result
v10
query
shell
v4
...
Testing
WIP